Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

361
Vistas
"Error: euclideanDistance: arr1.length !== arr2.length" in face-api

I am currently creating a facial recognition system using this API: https://github.com/justadudewhohacks/face-api.js/

Reference: https://blog.mdzulkarnine.com/building-face-recognition-api-with-nodejs-expressjs-mongodb-face-apijs

In client-side, after successful detection of the face it will fetch post request to the server and send the resizedDetection

        $("#face").attr("src",img_data);
        const input = await $('#face')[0];

        const detection = await faceapi.detectAllFaces(input).withFaceLandmarks().withFaceDescriptors();
        const resized = await faceapi.resizeResults(detection, displaySize);

        if(!fetched && resized) {
            fetched = true;

            await fetch('/establishment/verify', { 
                method: 'POST', 
                headers: {
                    "content-type": "application/json"
                }, 
                body:  JSON.stringify({ resized }) 
                // descriptor
            })
            .then((response)=> {
                console.log(response);
            });
        }

In the server, it will accept the resizedDetection from the client-side.

const verification_post = async (req, res) => {
    try {
        const resizedDetections = req.body.resized;

        let visitors = await Visitor.find();
        
        for(i=0;i<visitors.length;i++) {
            for (j = 0; j < visitors[i].descriptions.length; j++) {
                visitors[i].descriptions[j] = new Float32Array(Object.values(visitors[i].descriptions[j]));
            }
            visitors[i] = new faceapi.LabeledFaceDescriptors(visitors[i]._id.toString(), visitors[i].descriptions);
        }

        const faceMatcher = new faceapi.FaceMatcher(visitors, 0.6);
        console.log("Faces: ", visitors);
        console.log("Resized Detections: ", resizedDetections);
        const results = resizedDetections.map((des) => faceMatcher.findBestMatch(des.descriptor));
    } catch (error) {
        console.log(error);
        res.status(400).send(error);
    }
}

The visitors and resizedDetection is displaying correctly, but it is not proceeding to the part of results, and returning the error "Error: euclideanDistance: arr1.length !== arr2.length". Is there anyone who tried working with it?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda